package com.oscar.practice.shiro.biz.shiro;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
import org.springframework.stereotype.Component;

/**
 * 身份认证拦截器
 *
 * @author tongyufu
 *
 */
@Component
public class UserFormAuthenticationFilter extends FormAuthenticationFilter {

    @Override
    protected boolean onAccessDenied(ServletRequest request,
                                     ServletResponse response) throws Exception {
        System.out.println("=======UserFormAuthenticationFilter========");
        //当验证码验证失败时不再走身份认证拦截器
        if (request.getAttribute("CaptchaValidate") != null) {
            return true;
        }
        return super.onAccessDenied(request, response);
    }

}
